GetSchoolsAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 18
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index 0 8 1
1
import { Controller, Inject, UseGuards, Get, Query } from '@nestjs/common';
2
import { AuthGuard } from '@nestjs/passport';
3
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
4
import { SchoolView } from 'src/Application/School/View/SchoolView';
5
import { IQueryBus } from 'src/Application/IQueryBus';
6
import { GetSchoolsQuery } from 'src/Application/School/Query/GetSchoolsQuery';
7
import { Pagination } from 'src/Application/Common/Pagination';
8
import { PaginationDTO } from 'src/Infrastructure/Common/DTO/PaginationDTO';
9
import { RolesGuard } from 'src/Infrastructure/User/Security/RolesGuard';
10
import { Roles } from 'src/Infrastructure/User/Decorator/Roles';
11
import { UserRole } from 'src/Domain/User/User.entity';
12
13
@Controller('schools')
14
@ApiTags('School')
15
@ApiBearerAuth()
16
@UseGuards(AuthGuard('bearer'), RolesGuard)
17
export class GetSchoolsAction {
18
  constructor(
19
    @Inject('IQueryBus')
20
    private readonly queryBus: IQueryBus
21
  ) {}
22
23
  @Get()
24
  @Roles(UserRole.PHOTOGRAPHER)
25
  @ApiOperation({summary: 'Get all schools'})
26
  public async index(
27
    @Query() { page }: PaginationDTO
28
  ): Promise<Pagination<SchoolView>> {
29
    return await this.queryBus.execute(new GetSchoolsQuery(page));
30
  }
31
}
32